<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //元素
        //下标
        // length

        //数组取值超过长度会输出undefined
        //数组的length是最后一个元素的下标+1
        var arr = [123, 456, 789]

        // console.log(arr)
        // console.log(arr[1])
        // console.log(arr[4]) //undefind

        arr[100] = '666'

        // console.log(arr[4])
        // console.log(arr.length)

        //构造函数声明创建
        var arr1 = new Array()

        arr1[0] = 1
        arr1[1] = 2
        arr1[2] = 3

        console.log(arr1)

        var arr3 = [{
                name: 'tom'
            },
            [1, 2, 3, 4, 5],
            function () {
                console.log('这是数组中添加的方法')
            }
        ]
        console.log(arr3)
        console.log(arr3[0])
        console.log(arr3[2]())
    </script>
</body>

</html>